// 得到字符串中的首尾相同的最长子串

let s = 'bcabad'
let strArr = []

function longest(s) {
    if(s.length === 1) return s
    for(let i = 0; i < s.length; i++) {
        for(let j = i + 1; j < s.length; j++) {
            if(s[i] === s[j]) {
                strArr.push[i, j]
                break
            }
        }
    }
}


let len = 0
let res = []

for(let index = 0; index < strArr.length; index++) {
    if(strArr[index][0] - strArr[index][0] > len) {
        len = strArr[index][1] - strArr[index][0]
        res[0] = strArr[index][0]
        res[1] = strArr[index][1]
    }
}
